﻿using MediatR;
using S.EarTag.Domain.Model;
using S.EarTag.Infrastructure.Repository.Interface.IEarTagRepository;
using S.EarTag.Read.API.Mediator.MediatorCommand;

namespace S.EarTag.Read.API.Mediator.MediatorCommandHandler
{
    public class EarTagByIdCommandHandler : IRequestHandler<EarTagByIdCommand, EarTagModel>
    {
        private readonly IEarTagModelRepository _earTagModelRepository;
        public EarTagByIdCommandHandler(IEarTagModelRepository earTagModelRepository)
        {
            _earTagModelRepository= earTagModelRepository;
        }
        /// <summary>
        /// 根据Id查询耳标数据用于反填
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<EarTagModel> Handle(EarTagByIdCommand request, CancellationToken cancellationToken)
        {
            return await _earTagModelRepository.GetByIdEarTag(request.id);
        }
    }
}
